package com.gsm.dto;

import com.gsm.po.SysRole;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class SysUserDto {
    public interface insert {
    }

    public interface update {
    }

    private Long userId;
    /**
     * 用户名
     */
    @Length(message = "用户名长度不能大于14", max = 14, groups = insert.class)
    @Length(message = "用户名长度不能大于14", max = 14, groups = update.class)
    @NotBlank(message = "用户名不能为空", groups = insert.class)
    @NotBlank(message = "用户名不能为空", groups = update.class)
    private String userName;
    /**
     * 手机号
     */
    @Pattern(message = "手机号不符合规则", regexp = "^(1[3-9]\\d{9}$)", groups = insert.class)
    @Pattern(message = "手机号不符合规则", regexp = "^(1[3-9]\\d{9}$)", groups = update.class)
    @NotBlank(message = "手机号不能为空", groups = insert.class)
    @NotBlank(message = "手机号不能为空", groups = update.class)
    private String iphoneNo;
    /**
     * 密码明文
     */
    @NotBlank(message = "密码不能为空", groups = insert.class)
    private String po;
    /**
     * 密码密文
     */
    @NotBlank(message = "密码不能为空", groups = insert.class)
    private String pc;


    /**
     * 角色
     */
    @NotNull(message = "至少分配一个角色", groups = insert.class)
    @NotNull(message = "至少分配一个角色", groups = update.class)
    @Size(message = "至少分配一个角色", min = 1, groups = insert.class)
    @Size(message = "至少分配一个角色", min = 1, groups = update.class)
    private List<Long> sysRoles;
}
